<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>编码和解码</title>
        <script type="text/javascript">
            // 测试 encodeURI 和 decodeURI
            // URI: Uniform Resource Identifier, 统一资源标识符
            // URL: Uniform Resource Locator, 统一资源定位器

            const uri = '/user?username=张三丰' ;

            // 编码: 将人类易读的信息转换成机器易处理的信息
            let encoded = encodeURI( uri );
            console.log( encoded );

            // 解码: 将机器易处理的信息转换为人类易读的信息
            let decoded = decodeURI( encoded );
            console.log( decoded );

            console.log( '- - - '.repeat(10) );

            let e = encodeURIComponent( uri );
            console.log( e );

            let d = decodeURIComponent( e );
            console.log( d );
        </script>
    </head>
    <body>
        
    </body>
</html>